<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>"/>
	<title><s:text name="sys.app_title" /></title>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/dtree.css"/>
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="js/category.js"></script>
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
		<!-- DWR -->
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	   	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>
	
	<script type="text/javascript">
		function showCategory(){
			var x = window.showModalDialog("/SSS/page/search/CategoryTree.jsp",null,"dialogWidth=300px;dialogHeight=400px");
		  // alert("从类型树页面传过来的数据为"+x);
			var catid=x.substring(0, x.indexOf(",", 0));
			var catname=x.substring((x.indexOf(",", 0)+1), x.length);
			var selectCategory=document.getElementById("selectCategory");
			var category=document.getElementById("category");
			if(catname!="undefined" && catid!="undefined"){
				category.value=catname;
				selectCategory.value=catid;
			}
		}
		function showDeclarationDepartment(){
			var x = window.showModalDialog("/SSS/page/search/DepartmentTree.jsp",null,"dialogWidth=300px;dialogHeight=400px");
		
		
		//	alert("从类型树页面传过来的数据为"+x);
			var depid=x.substring(0, x.indexOf(",", 0));
			var depname=x.substring((x.indexOf(",", 0)+1), x.length);
			var ddName = document.getElementById("declarationDepartment");
			var ddid = document.getElementById("ddid");
			if(depname!="undefined" && depid!="undefined"){
				ddid.value = depid;
				ddName.value = depname;
			}
		}
		function showEmployDepartment(){
			var x = window.showModalDialog("/SSS/page/search/DepartmentTree.jsp",null,"dialogWidth=300px;dialogHeight=400px");
		//	alert("从类型树页面传过来的数据为"+x);
			var depid=x.substring(0, x.indexOf(",", 0));
			var depname=x.substring((x.indexOf(",", 0)+1), x.length);
			var edName = document.getElementById("employDepartment");
			var edid = document.getElementById("edid");
			if(depname!="undefined" && depid!="undefined"){
				edName.value = depname;
				edid.value = depid;
			}
		}
       function showUser(){
    	   var vRValue = window.showModalDialog("/SSS/page/basic/depTree_1.jsp",null,"dialogWidth=600px;dialogHeight=450px;status=0;scroll=0");
   		if(vRValue == undefined){
   	  	  	vRValue = '';
   	  	}
   		var uid = (vRValue=='')?'':vRValue.split(',')[0];
   		var uname = (vRValue=='')?'':vRValue.split(',')[1];
   		if(uid != undefined && uname != undefined){
   			$('input#user').val(uname);
   		}
           }
		
	</script>	
  </head>
  
  <body>
	  <div class="mainContainer">
	    <div class="headerTitle">用户自定义查询</div>
	  	<div>
	  		<span>申请部门:</span><input type="checkbox" value="declarationDepartment"/>&nbsp;&nbsp;&nbsp;
	  		<span>使用部门:</span><input type="checkbox" value="employDepartment" />&nbsp;&nbsp;&nbsp;
	  		<span>使用人:</span><input type="checkbox" value="user" />&nbsp;&nbsp;&nbsp;
	  		<span>会计科目:</span><input type="checkbox" value="accountSubject" />&nbsp;&nbsp;&nbsp;
	  		<span>凭证编号:</span><input type="checkbox" value="orderId" />&nbsp;&nbsp;&nbsp;
	  		<span>资产类别:</span><input type="checkbox" value="category" />&nbsp;&nbsp;&nbsp;
	  		<span>资产状态:</span><input type="checkbox" value="assetStatus" />&nbsp;&nbsp;&nbsp;
	  		<span>时间范围:</span><input type="checkbox" value="timeScope" />&nbsp;&nbsp;&nbsp;
	  	</div>
	  	<div id="optionScope">
		  	<div id="declarationDepartmentDiv" style="display: none">
		  		<span>申请部门:</span>
		  			<input type="hidden" id="ddid"/>
		  			<input type="text" readonly="readonly" disabled="disabled" id="declarationDepartment" name="declarationDepartment" />
					<img src="images/showDep.gif" onclick="showDeclarationDepartment()" style="cursor: pointer;" alt="选择部门" title="选择部门" />
			</div>
			<div id="employDepartmentDiv">
		  		<span>使用部门:</span>
		  			<input type="hidden" id="edid"/>
		  			<input type="text" readonly="readonly" disabled="disabled" id="employDepartment" name="employDepartment"/>
					<img src="images/showDep.gif" onclick="showEmployDepartment()" style="cursor: pointer;" alt="选择部门" title="选择部门" />
			</div>
			<div id="userDiv">
				<span>使用人:</span>
					<input type="text" disabled="disabled" id="user" name="user"/>
					<img src="images/showDep.gif" onclick="showUser()" style="cursor: pointer;" alt="选择使用人" title="选择使用人" />
			</div>
			<div id="accountSubjectDiv">
				<span>会计科目:</span>
					<select disabled="disabled" id="accountSubject" name="accountSubject">
						<option selected="selected" value="">==请选择==</option>
						<option value="1">低值易耗品摊销</option>
						<option value="2">办公用品</option>
						<option value="3">固定资产</option>
						<option value="4">其他</option>
					</select>
			</div>
			<div id="orderIdDiv">
				<span>凭证编号:</span>
					<input type="text" disabled="disabled" id="orderId" name="orderId"/>
			</div>
			<div id="categoryDiv">
				<span>资产类别:</span>
				<s:hidden id="selectCategory" name="catid"/>
				<input type="text" id="category" name="category" readonly="readonly" style="width:154px" disabled="disabled"/>
				<img src="images/showDep.gif" onclick="showCategory()" style="cursor: pointer;" alt="选择资产类别" title="选择资产类别" />
			</div>
			<div id="assetStatusDiv">
				<span>资产状态:</span>
				<select id="assetStatus" name="assetStatus" disabled="disabled">
					<option selected="selected" value="">==请选择==</option>
					<option value="1">申报</option>
					<option value="2">入库</option>
					<option value="3">出库</option>
					<option value="4">报废</option>
					<option value="5">在用</option>
				</select>
			</div>	
			<div id="timeScopeDiv">
				<span>时间范围:</span>
				<input type="text"  onclick="WdatePicker()" style="width:65px" id="timeScope1" />--<input type="text" value="" onclick="WdatePicker()" style="width:65px" id="timeScope2" onchange=""/>
			   
			</div>
	  	</div>
	  	
	<!-- form表单自动提交给action处理 -->
<form action="query/userDefinedSearch.action" method="post" id="form1" >
	  	<input type="hidden" value="" id="dd" name="declarationDepartment" />
	  	<input type="hidden" value="" id="ed" name="employDepartment"/>
	  	<input type="hidden" value="" id="us" name="user"/>
	  	<input type="hidden" value="" id="as" name="accountSubject"/>
	  	<input type="hidden" value="" id="ca" name="category"/>
	  	<input type="hidden" value="" id="ts1" name="timeScope1"/>
	  	<input type="hidden" value="" id="oi" name="orderId"/>
	  	<input type="hidden" value="" id="ass" name="assetStatus"/>
	  	<input type="hidden" value="" id="ts2" name="timeScope2"/>
	  	<input type="button" value="搜索" name="search" onclick="handleSubmit()"/>
</form> 
<hr /> 
<table class="gridTable"><tr><td class="gridData">  
	    	<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
					  			<!-- 数据表头 -->
						  <td width="3%"><input id="checkAll" type="checkbox" name="check" value="checkbox" /></td> 
					      <td width="8%">资产名称</td>	
						  <td width="8%">资产简称</td>
						  <td width="12%">资产状态</td>
						  <td width="10%">资金来源</td>
						  <td width="6%">申请部门</td>
						  <td width="6%">生产日期</td>
						  <td width="6%">使用期限</td>
						  <td width="9%">预计停用日期</td>
						  <td width="9%">实际停用日期</td>
						  <td width="3%">单价</td>
						  <td width="6%">计量单位</td>
						  <td width="6%">资产规格</td>
						  <td width="8%">生产厂家</td>
						</tr>
								          
								<!-- 数据 -->
						<s:iterator var="ac" value="pagination.dataList">    
						<tr class="dataRow" id="<s:property value='#ac.acid'/>" ondblclick="updateAssetCard('<s:property value="#ac.acid" />')">
						  <td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid'/>" id="selectItem" /></td>
						  <td><s:property value="#ac.acname" /></td>
						  <td><s:property value="#ac.acanothername"/></td>
						  <td> 
						     <s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						             <s:property value="desc"/>  
						       </s:if>
						     </s:iterator>
						     
						  </td>
						 
						  <td><s:property value="#ac.assetcomefrom"/></td>
						  <td><s:property value="#ac.reportdepartment"/></td>
						  <td>
						    <fmt:formatDate value="${ac.producedate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td><s:property value="#ac.lifetime"/></td>
						  <td>
						     <fmt:formatDate value="${ac.planstopdate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td>
						     <fmt:formatDate value="${ac.actualstopdate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td><s:property value="#ac.reportprice"/></td>
						  <td><s:property value="#ac.category.catunit"/></td>
						  <td><s:property value="#ac.category.catnorms"/></td>
						  <td><s:property value="#ac.producer"/></td>  
						</tr>
						</s:iterator><%-- 数据循环结束 --%>	
     				</table><%-- 数据表格结束 --%>		
 	            </td>
 	       </tr>
 	       <tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>  
 	  </table> 	    
	  </div>

	  
	  
	  <script type="text/javascript">	  
	  $(document).ready(function(){
			$("#optionScope > div").css("display","none");
		  	$(":checkbox").click(function(){
			  	if($(this).attr("checked")){
			  		$("#"+this.value).attr("disabled","");
			  		$("#"+this.value+"Div").css("display","");
			  	}else{
			  		$("#"+this.value).attr("disabled","disabled");
			  		$("#"+this.value).val("");
			  		$("#"+this.value+"Div").css("display","none");
			  	}
		  	});
	  });

	  function handleSubmit(){
		  $("#dd").val($("#declarationDepartment").val());
		  $("#ed").val($("#employDepartment").val());
		  $("#us").val($("#user").val());
		  $("#as").val($("#accountSubject").val());
		  $("#ca").val($("#category").val());
		  $("#ts1").val($("#timeScope1").val());
		  $("#ts2").val($("#timeScope2").val());
		  $("#oi").val($("#orderId").val());
		  $("#ass").val($("#assetStatus").val());
		  if($("#dd").val()==''&&$("#ed").val()==''&&$("#us").val()==''&&$("#as").val()==''&&$("#ca").val()==''&&$("#ts1").val()==''&&$("#ts2").val()==''&&$("#oi").val()==''&&$("#ass").val()==''){
		   alert("请输入你需要搜索的内容！");
		  return ;
		  }
		 $("#form1").submit();
	  }
	  </script>
	  
  </body>
</html>
